$(function(){
	/*
	$('.message-author').click(function (e) {
		e.preventDefault();
		
	});
	*/
	$('.message-header').click(function (e) {
		if($(e.target).is('a')) {
			return true;
		}
		e.preventDefault();
		$(this).parent().toggleClass('collapsed');  
	});
	
	$('#answer-tabs a').click(function (e) {
		  e.preventDefault();
		  $(this).tab('show');
	});
	$("#aforward").click(function(e){
		e.preventDefault();
		$('#tab_forward').tab('show');
		$('#message-answer-band').toggleClass('hide');
		$('#answer-complete-box').toggleClass('hide');
		$('#subject').parents('.control-group:first').removeClass('hide');
		return false;
	});
	// 
	$("#tab_forward").click(function(e){
		$('#subject').parents('.control-group:first').removeClass('hide');
	});
	$("#aanswer").click(function(e){
		e.preventDefault();
		$('#tab_answer').tab('show');
		$('#message-answer-band').toggleClass('hide');
		$('#answer-complete-box').toggleClass('hide');
		return false;
	});
	$('#adcc').click(function(){$('#receivers_ccs').parents('.control-group:first').toggleClass('hide');});
	$('#adcci').click(function(){$('#receivers_cci').parents('.control-group:first').toggleClass('hide');});
	$('#changesubject').click(function(){$('#subject').parents('.control-group:first').toggleClass('hide');});
	// Add Ellipisis on hive blockquote
	$('.message-content').each(function(){
		var $ellispsis = $('<div class="content-collapser" role="button"><i>&nbsp;</i></div>');
		var $blockquotes = $(this).find('.gmail_quote:first,.hive-blockquote:first');
		if($blockquotes.length > 0 ) {
			if($blockquotes.length > 1 ) {
				var $blockquote = $(this).find($blockquotes[0]);
			} else {
				var $blockquote = $blockquotes;
			}
			$ellispsis.click(function(){
				$blockquote.toggleClass('hide');
			});
			$blockquote.addClass('hide');
			$ellispsis.insertBefore($blockquote);
		}
	});
});